<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta content="ie=edge" http-equiv="X-UA-Compatible"/>
    <title>Document</title>
    <style>
        .print {
            font-family: "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
            "PingFang SC", "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei",
            sans-serif;
        }

        @page {
            margin: 0;
        }
    </style>
</head>
<body>
<div id="app" class="print">
    <div id="content"></div>
    <img id="qrcode" src="" style="margin-left: 20px;margin-top: 10px"/>
</div>
<script>
    const ipcRenderer = require('electron').ipcRenderer
    // 监听渲染线程传过来的webview-print-render事件
    ipcRenderer.on('webview-print-render', (event, data) => {
      console.log('打印内容：')
      console.log(data)
      // 把内容渲染到页面上
      document.getElementById('content').innerHTML = data
      // 通过ipcRenderer对象的sendToHost方法和渲染线程通讯，告诉渲染线程打印的内容已经准备完毕，请开始打印操作
      ipcRenderer.sendToHost('webview-print-do')
    })
</script>
</body>
</html>
